import java.util.Random;
public class 实验一 {
    public static void main(String[] args) {
        int num1 , num2 , Rnumber;
        int Detection1,Detection2;
        int[] equation =new int[50];
        char symble;
        Random r=new Random();
        for(int i=0;i<50;i++){
            for(int j=0;j<5;j++){
            do {
                Detection1=Detection2=0;
                Rnumber = (short) r.nextInt(1);
                if(Rnumber ==1) {
                    do {
                        int num = r.nextInt(2) * 2 - 1;
                        num1 = (short) r.nextInt(201) * num;
                        num2 = (short) r.nextInt(201) * num;
                } while (check1(num1) == 0 || check1(num2) == 0);
                    Detection1= addition(num1,num2);
                    equation[i]=Detection1;
                }
                else {
                    do {
                        int num = r.nextInt(2) * 2 - 1;
                        num1 = (short) r.nextInt(201) * num;
                        num2 = (short) r.nextInt(201) * num;
                } while (check1(num1) == 0 || check1(num2) == 0);
                    Detection2= subtraction(num1,num2);
                    equation[i]=Detection2;
                }
            }while (check2(Detection1)==0&&check2(Detection2)==0);
            if(Rnumber ==1){
                symble ='+';
                exportation1(i,symble,num1,num2,equation);
            }
            else{
                    symble ='-';
                exportation2(i,symble,num1,num2,equation);
            }
            }
        }
    }
    public static int addition(int number1, int number2){
        int sum=number1+number2;
        return sum;
    }
    public static int subtraction(int number1, int number2){
        int sum=number1-number2;
        return sum;
    }
    public static void exportation1(int i, char symble, int number1, int number2, int[] equation){

        if(number1>=0&&number2>=0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble + number2 +"="+ equation[i]);
        }
        else if(number1<0&&number2>=0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble + number2 +"="+ equation[i]);
        }
        else if(number1<0&&number2<0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble +"("+ number2+")"+"="+ equation[i]);
        }
    }
    public static void exportation2(int i,char symble,int number1, int number2,int[] equation){

        if(number1>=0&&number2>=0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble + number2 +"="+ equation[i]);
        }
        else if(number1<0&&number2>=0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble + number2 +"="+ equation[i]);
        }
        else if(number1<0&&number2<0){
            System.out.println(""+(i+1)+":\t"+ number1 + symble +"("+ number2+")" +"="+ equation[i]);
        }
    }
    public static int check1(int num){
        if(num<0||num>100){
            return num;
        }
        else
            return 0;
    }
    public static int check2(int num){
        if(0<num&&num<100){
            return num;
        }
        else
            return 0;
    }
}
